package Week4.J0508;

import java.util.*;

public class 集合_xv {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        TreeSet<Integer> treeSet = new TreeSet<>();
        int x = 0;
        while (n-- != 0) {
            x = scanner.nextInt();
            treeSet.add(x);
        }
        while (m-- != 0) {
            x = scanner.nextInt();
            treeSet.add(x);
        }

        for (int a : treeSet) {
            System.out.print(a + " ");
        }
    }
}
